# Contributor: Hoang Nguyen <folliekazetani@protonmail.com>
# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=stern
pkgver=1.21.0
pkgrel=0
pkgdesc="Multi pod and container log tailing for Kubernetes"
url="https://github.com/stern/stern"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/stern/stern/archive/refs/tags/v$pkgver.tar.gz"

build() {
	GOLDFLAGS="
	-X github.com/stern/stern/cmd.version=$pkgver
	-X github.com/stern/stern/cmd.commit=AlpineLinux
	-X github.com/stern/stern/cmd.date=$(date +%FT%T%Z)
	"
	go build -v -o bin/$pkgname -ldflags "$GOLDFLAGS"
	./bin/stern --completion bash > stern.bash
	./bin/stern --completion zsh > stern.zsh
	./bin/stern --completion fish > stern.fish
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/$pkgname "$pkgdir"/usr/bin/$pkgname

	install -Dm644 stern.bash \
		"$pkgdir"/usr/share/bash-completion/completions/stern
	install -Dm644 stern.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_stern
	install -Dm644 stern.fish \
		"$pkgdir"/usr/share/fish/completions/stern.fish
}

sha512sums="
e1e0b73cbddd6dd7729444f2ef9aa787a64f7ba70e951c39012e9d5faef6834363049f02f03163d48e94908ef238394878178b5a6dbcc22fa6a8d349049c9467  stern-1.21.0.tar.gz
"
